<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>OurBarangay.com >> Sitios</title>
        <link rel="Stylesheet" href="<?php echo base_url();?>assets/css/general.css" />
        <link rel="Stylesheet" href="<?php echo base_url();?>assets/css/common.css" />
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/jquery/js/jquery-1.6.2.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/asynch.js"></script>
        <style type="text/css">
            .body_right {
                background-color: #fff;
            }
            .prim_inf {
                padding: 0px 8px;
            }
            td.info {
                padding: 7px;
            }
            td.commit {
                text-align: right;
                font-size: 11px;
            }
            td.commit a {
                color: #333;
            }
            td.commit a:hover {
                text-decoration: none;
            }
            textarea {
                width: 649px;
                height: 200px;
            }
            input[type="text"], input[type="password"], .unedit_info {
                width: 258px;
            }
            textarea {
                
            }
        </style>
    </head>
    <body>
        <div class="container">
            <?php $this->load->view('main_admin_panel'); ?>
            <?php $this->load->view('main_head'); ?>
            <div class="body">
                <?php $this->load->view('main_body_left'); ?>
                <div class="body_right">
                    <div class="prim_inf">
                        <div class="main_article">
                            <span class="main_article_title">
                                <?php if($this->input->get('sitio_id_pk')) { ?>
                                     Edit Sitio Article
                                <?php } else { ?>
                                     Create a New Sitio
                                <?php } ?>
                            </span>
                            <hr/>
                            <table>
                                <tr>
                                    <td class="info">
                                        <span class="left_box_art_details">Sitio Article Post under</span>
                                        <br />
                                        <span class="unedit_info"><?php echo $this->session->userdata('barangay') . ', ' . $this->session->userdata('municipality') . ', ' . $this->session->userdata('province');?></span>
                                    </td>
                                    <td rowspan="4" class="article_img">
                                        <img src="<?php echo base_url()?>assets/css/uploads/sample_pic.png" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="info">
                                        <span class="left_box_art_details">A Sitio Post by </span>
                                        <br />
                                        <span class="unedit_info"><?php echo $this->session->userdata('username');?></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="info">
                                        <span class="left_box_art_details">Sitio Name</span>
                                        <br />
                                        <input type="text" id="l_name" value="<?php if($this->input->get('sitio_id_pk')) { ?><?=$sitios['sitio_name']?><?php } ?>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="info">
                                        <span class="left_box_art_details">Sitio Address</span>
                                        <br />
                                        <input type="text" id="l_addr" value="<?php if($this->input->get('sitio_id_pk')) { ?><?=$sitios['sitio_address']?><?php } ?>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="info" colspan="2">
                                        <span class="left_box_art_details">Sitio Details</span>
                                        <br />
                                        <textarea id="l_det"><?php if($this->input->get('sitio_id')) { ?><?=$sitios['sitio_details']?><?php } ?></textarea>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="commit">
                                        <a href="javascript:void(0)" id="sitio_submit_ae"><?php if($this->input->get('sitio_id_pk')) { ?>Update Sitio<?php } else { ?>Add New Sitio<?php } ?></a>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="footer">
                <div class="footer_brgy_info">
                    Brgy Info
                </div>
                <div class="footer_sysnet">
                    Sysnet
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $(document).ready(function() {
                <?php if($this->session->userdata('barangay_id') != '' || $this->session->userdata('barangay_id') != null) { ?>
                /*
                 * Asynchronous requests that are common
                 **/
                weeklyBulletin();
                latestBarangayUpdate();
                /*
                 * Asynchronous requests that are native to the page
                 **/
                //brgyDesc('edit');
                
                // In the future, the way should be like below
               //<php if($this->input->get('sitio_id_pk')) { ?>Update Sitio<php } else { ?>Add New Sitio<php } ?>
                
                var crudSitios = $("#sitio_submit_ae").click(function(){
                    $.ajax({
                        type:"post",
                        url:"<?php echo base_url();?>index.php/sitios/crudSitios/ajax",
                        data:"l_submit=y&l_id=<?php echo $this->input->get('sitios_id'); ?>&l_name="+$("#l_name").val()+"&l_addr="+$("#l_addr").val()+"&l_det="+$("#l_det").val(),
                        success:function(data) {
                            window.location.href="<?php echo base_url();?>index.php/sitios";
                        },
                        error:function(data, textStatus) {
                            document.write(textStatus);
                        }
                    });
                });
                
                <?php } ?>
            });
        </script>
    </body>
</html>
